package cn.wolfcode.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Setter
@Getter
@ToString
public class Employee implements Serializable {
    private Long id;
    private String name;
    private String password;
    private String email;
    private Integer age;

    // 不使用包装类型 管理员是就是true 不是就是false 没有null
    private boolean admin;

    //private Long deptId;

    private boolean status = true;

    // 关联属性
    private Department dept = new Department();

    // 角色
    private List<Role> roles = new ArrayList<>();


    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("name", name);
        map.put("email", email);
        map.put("age", age);
        map.put("admin", admin);
        map.put("status", status);
        //map.put("dept", dept);
        //map.put("roles", roles);
        return JSON.toJSONString(map);
    }

    public Long getDeptId() {
        return dept.getId();
    }

}

